<template>
	<view :style="colorStyle">
		<view class='commission-details'>
			<view class='promoterHeader bg-color'>
				<view class='headerCon '>
					<view class="acea-row row-between-wrapper" style="padding: 10px 0px;">
					<view>
						<view class='name'>我的基础值</view>
						<view class='money'><text class='num'>{{jichuzhi}}</text></view>
			
					</view>
					<image src="@/static/images/zxc.png" mode="" style="width: 65rpx;height: 65rpx;"></image>
					</view>
					<view style="display: flex;align-items: center; justify-content: center;">
						<view style="padding: 5px 10px;margin: auto;border:1px solid #fff;border-radius: 5px;" @click="goUrl()">换货积分互转</view>
						<view style="padding: 5px 10px;margin: auto;border:1px solid #fff;border-radius: 5px;" @click="exchangeQiquan">转入期权值</view>
					</view>
				</view>
			</view>
			<view class='sign-record'>
					<view class='list'>
						<view class='item' v-for="(item) in recordList ">
							<view class='listn'>
								<view class='itemn acea-row row-between-wrapper'>
									<view class="title">
										<view class='name line1'>{{item.title}}</view>
										<view>{{item.add_time}}</view>
								
									</view>
									<view class='num font-color' v-if="item.pm == 1">+{{item.number}}</view>
									<view class='num' v-else>-{{item.number}}</view>
								</view>
						</view>
					</view>
				</view>
				<view class='loadingicon acea-row row-center-wrapper' v-if="recordList.length">
					<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
				</view>
				<view v-if="recordList.length < 1 && page > 1">
					<emptyPage :title='$t(`暂无数据~`)'></emptyPage>
				</view>
			</view>
		</view>
		<!-- #ifdef H5 -->
		<home></home>
		<!-- #endif -->
	</view>
</template>

<script>
	import {
		getUserInfo,getJichuzhi
	} from '@/api/user.js';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	// #ifdef MP
	import authorize from '@/components/Authorize';
	// #endif
	import emptyPage from '@/components/emptyPage.vue'
	import home from '@/components/home';
	import colors from '@/mixins/color.js';
	export default {
		components: {
			// #ifdef MP
			authorize,
			// #endif
			emptyPage,
			home
		},
		mixins: [colors],
		data() {
			return {
				name: '',
				type: 0,
				page: 1,
				limit: 15,
				loading: false,
				loadend: false,
				loadTitle: this.$t(`加载更多`),
				recordList: [],
			
				recordCount: 0,
				extractCount: 0,
				times: [],
				userInfo:[],
				fudou:'',
				jichuzhi:0
			};
		},
		computed: mapGetters(['isLogin']),
		onLoad() {
			if (this.isLogin) {
				this.getRecordList()
			} else {
				toLogin();
			}
		},
		onShow: function() {
			let that = this;
			that.getRecordList()
			getUserInfo().then(res=>{
				that.fudou = res.data.fudou,
				that.jichuzhi = res.data.jichuzhi
			})
			
		},
		methods: {
			exchangeQiquan(){
				uni.navigateTo({
					url:"/pages/jichu_qiquan/jichu_qiquan"
				})
			},
			goUrl(){
				uni.navigateTo({
					url:"/pages/huanhuo/huanhuo"
				})
			},
			getRecordList: function() {
				let that = this;
				let page = that.page;
				let limit = that.limit;
				if (that.loading) return;
				if (that.loadend) return;
				that.loading = true;
				that.loadTitle = '';
				getJichuzhi({
					page: page,
					limit: limit
				}).then(res => {
					
					let loadend = res.data.length < that.limit;
					that.loadend = loadend;
					that.recordList = that.$util.SplitArray(res.data, that.recordList);
					that.$set(that, 'recordList', that.recordList);
					that.loadTitle = loadend ? that.$t(`我也是有底线的`) : that.$t(`加载更多`);
					that.page += 1;
					that.loading = false;
				}).catch(err => {
					that.loading = false;
					that.loadTitle = that.$t(`加载更多`);
				})
			},
			
		},
		onReachBottom: function() {
			this.getRecordList();
		}
	}
</script>

<style scoped lang="scss">
	.commission-details .promoterHeader .headerCon .money {
		font-size: 36rpx;
	}

	.commission-details .promoterHeader .headerCon .money .num {
		font-family: 'Guildford Pro';
	}
	.sign-record .list .item .listn .itemn .name{
		width: 100%;
		// max-width: 100%;
		white-space: break-spaces;
	}
	.sign-record .list .item .listn .itemn .title {
		padding-right: 30rpx;
		flex: 1;
	}
</style>
